let express = require("express")(); 
let expressStatic = require("express-static"); 
const port = 80;
let mysql = require("mysql");
let sql = mysql.createConnection({
	host     : 'localhost',
	user     : 'root',
	password : '123456',
	database : 'news'
});
sql.connect();
express.get("/getnewsList",function(request,response){
	sql.query(`SELECT id,name,item,photo FROM user`,function(error,data){
		response.send(data);
	})
})
express.get("/getnews",function(request,response){
	sql.query(`SELECT * FROM user WHERE id=${request.query.id}`,function(error,data){
		if(error){
			response.send("error");
			console.log(error)
		}else{
			response.send(data);
		}
	})
})
express.use(expressStatic(__dirname + '/static'));
console.log(`running at ${port}`)
express.listen(port)